package com.sky.controller.admin;

import com.obs.services.ObsClient;
import com.obs.services.exception.ObsException;
import com.obs.services.model.AccessControlList;
import com.obs.services.model.HeaderResponse;
import com.obs.services.model.PutObjectResult;
import com.sky.constant.MessageConstant;
import com.sky.result.Result;
import com.sky.utils.HWeiUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;



/**
 * $
 *
 * @return $
 */
@Api(tags = "通用接口")
@Slf4j
@RestController
@RequestMapping("/admin/common")
public class CommonController {
    /**
     * 文件上传
     */
    @Autowired
    private HWeiUtil hWeiUtil;
    @PostMapping("/upload")
    @ApiOperation("文件上传")
    public Result<String> upload(MultipartFile file) {
        log.info("文件上传：{}", file.getOriginalFilename());
        try {
            String uploadFile = hWeiUtil.uploadFile(file);
            return Result.success(uploadFile);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
